﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication1
{
    public partial class WebForm3 : System.Web.UI.Page
    {
        private SqlHelper sqlHelper = new SqlHelper();
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            string name = UserName.Text;
            string gender = Gender_female.Checked ? "1" : "0";
            string age = Age.Text;
            string pwd = Password.Text;
            string sql = "insert into Student (Name,Sex,Age,[pwd]) values (@name,@gender,@age,@pwd)";
            SqlParameter[] pars =
            {
                new SqlParameter("@name",name),
                new SqlParameter("@pwd",pwd),
                new SqlParameter("@age",age),
                new SqlParameter("@gender",gender)
            };
            if (sqlHelper.Execute(sql, pars))
            {
                Literal1.Text = "注册成功，<a href='WebForm.aspx'>去登陆</a>";
            }
            else
            {
                Literal1.Text = "注册失败!";
            }
        }
    }
}